package cn.edu.sdjzu.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @SentinelResource(
            value="helloResource",
            fallback="fallbackHello",
            blockHandler="blockHello"
    )
    @GetMapping("/hello")
    public String hello() {
        return "Hello World";
    }
    public String fallbackHello() {
        return "服务器繁忙，请稍后再试（Fallback）";
    }
    public String blockHello(BlockException exception) {
        return "请求过多，请稍后再试（Block）";
    }
}
